package com.aio.kgo.simple.form.common.field.config;

import com.aio.kgo.simple.form.common.domain.definition.FieldVerifyDefinition;
import com.kgo.flow.common.domain.amis.AmisOption;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @author lizhenming
 * @desc: 组件配置
 * @date 2023/12/25 22:19
 */
@Data
public class ElementConfig {
    /**
     * 是否必须
     */
    private boolean required;
    /**
     * 默认值
     */
    private Object defaultValue;
    /**
     * 格式
     */
    private String format;
    /**
     * 可选项
     */
    private List<AmisOption<Object>> options = new ArrayList<>();
    /**
     * 校验规则
     */
    private List<FieldVerifyDefinition> verifyList;

    public void addOption(Object key, String value) {
        addOption(key, value, false);
    }

    public void addOption(Object key, String value, Boolean selected) {
        options.add(new AmisOption(value, key, selected));
    }


}
